Copyright: Trapper Copyright® 1993-1994 Presley Computing


Trapper

Unregistered Software - Please Register today!

Error Trap Code Generation

     Trapper is a Code Generation tool that is capable of reading Basic text files and generating standard error trapping for each procedure in the file.  The best way to find out what Trapper does is to try it.

     Trapper will not over-write your existing code.  Trapper will not over-write any existing file unless you tell it to do so.  Try it with this in mind and see how Trapper can work for you.

Copyright

Please Register

What Trapper Does...

When to use Trapper

Tips

Thank You

Read This

Trapper is Simple!  Here is how to get started...

•	Select File command button

Click this button to get started.  A common dialog will be displayed.  Select the source file to "Trap" in the list and click on OK.
Another dialog will be displayed.  The proposed output file will be entered in the File Name field for you.  (Trapper automatically adds the .ERR extension to the source file name.)  If this is adequate, click on OK to close the dialog.  If the output file exists, Trapper will ask you if you want to over-write the file.  Select Yes if you want to over-write the file, or No to go back and choose another file name for the output.

•	Go

This command button will not be enabled until you first select Source and Output files.  Once it is enabled, click on this Command to start Trapper!
It's that easy!

•	Exit (Click this command button when you are done.)

When finished, you will need to load your project into Visual Basic.  To see the results of Trapper, Remove the original file from your project.  Then Add the "trapped" file, using the File Add menu.

Note: The default extension for Trapper files is .ERR, therefore they will not normally be displayed in Visual Basic's File Add menu.  In the File Type list, choose All Files to display the "trapped" files.

•	Important note:  Trapper assumes that you have the Global constants defined for the Visual Basic MsgBox function.  You need to have IDRETRY, IDABORT, IDIGNORE, MB_ICONEXCLAMATION, and MB_ABORTRETRYIGNORE defined as a minimum.  These constants are located in the CONSTANT.TXT file distributed with Visual Basic.


COPYRIGHT
Trapper is Copyright © 1993-1994 Jack Presley Computing

Portions of this program are Copyright Microsoft Corporation.

Visual Basic is a registered trademark of Microsoft Corporation.

Please support Shareware

You may do so by only distributing un-registered copies of this program and all associated files.  Please do not distribute registered versions of this program.  If you have a registered copy, but you did not register it, please register it.  See Please Register for details.

If you want to give this program to a friend, please give them the TRAP.EXE file, which contains all required files.  Better yet, tell them how to download it from CompuServe.

Please do not upload this program to any electronic bulletin board system.
This includes CompuServe, Prodigy, all major and local BBS's.

Thanks for trying Trapper!

Contents


PLEASE REGISTER
Unregistered Software - Please Register today!

Please Register

Trapper is Shareware

     You may use Trapper on a trial basis.  If you find it useful, please register it using CompuServe's ShareWare REGistration database.  Type GO SWREG at the ! prompt and register program #2360.

     Trapper registration is $20 (U.S.)  Registration will entitle you to a registered copy and unlimited technical support.

To Register:

•	GO SWREG at any CompuServe ! prompt.  Follow the prompts to register program #2360.  CompuServe will bill you for the registration and will notify us of your registration.  As soon as I am notified, I will ask you (via CIS Mail) if you would like me to eMail you your registered copy.  Receiving CIS Mail is free if you are on the Standard Pricing Plan.  I will confirm shipment with you before I send anything.

•	U. S. Mail is another option.  Send $20 to Presley Computing at the address below and I will return you a registered copy.

•	ORDER.WRI should have been included with Trapper.  It is a Windows Write file that contains more ordering information.

     If you do not have a CompuServe membership, please consider joining. You will find a wealth of information in the various forums.  Technical Support is only available electronically (no telephone support).

How to contact Presley Computing:

1	Leave a message to Jack Presley 70700,166 in section 17 (Third-Party) of the MSBASIC forum on CompuServe.

2	Electronic Mail to Jack Presley 70700,166 via CompuServe works easily well.  Internet to 70700.166@Compuserve.com.  Note there are no commas in the Internet address.

3	U. S. Mail to Presley Computing
     Jack Presley
     Presley Computing
     29322 Mandetta Drive
     Fair Oaks Ranch, Texas 78006-4529


WHAT TRAPPER DOES...
Unregistered Software - Please Register today!

What Trapper Does...

The easiest way to find out what Trapper does is to use it.

Trapper reads your Basic source code (saved in text format) and adds standard error trapping to your programs.

For VBDOS folks, Trapper only adds error trapping to Procedures (Subs and Functions) and does not affect module level code.

Trapper reads the name of the Procedure from the Sub/Function line and uses the name of the procedure to create meaningful labels.

After finding a procedure, Trapper inserts an On Error Goto Trap_Procedure statement at the beginning of the procedure.  At the end of the procedure, it adds:

Exit Sub/Function ' to avoid the error trap if
                  ' no error exists.

Trap_Procedure:
    Select Case MsgBox(Error$, MB_ICONQUESTION + MB_ABORTRETRYIGNORE) ' all on one line
    Case IDABORT
        Exit Sub/Function
    Case IDRETRY
        Resume
    Case IDIGNORE
        Resume Next
    End Select
End Sub/Function

Trapper shows some intelligence!  Trapper will leave your special error handling procedures alone.  Trapper will replace any "On Error Goto 0" statements it finds with "On Error Goto Trap_Procedure" as appropriate.

This allows you to do in-line error checking in parts of your procedures while you are writing your code.  You can use On Error Goto 0 while developing your application so that VB will display any unexpected errors.  Then when you are done adding the error checking for all those errors that you might expect, you may run Trapper.  Trapper will add this standard error checking to handle any unexpected errors.


WHEN TO USE TRAPPER
Unregistered Software - Please Register today!

When to use Trapper

You will want to use Trapper for most projects...

But at the appropriate time.

"When is the appropriate time?"  Good question!

I suggest you use Trapper at the end of the development cycle.  Most developers prefer to leave general error trapping turned off until their project is about complete.  This allows you to see the errors happen, when they happen--Visual Basic will immediately stop and show you the offending code.  With general error trapping enabled, it would make a little more difficult to see the errors as the happen.

The purpose of Trapper is to guard against those unexpected errors and provide a graceful, professional way for your application to handle them.

How do I see where the error occurred AFTER I run Trapper?

After you run Trapper, all unexpected errors will result in a standard Message Box "Abort, Retry, Ignore?"  When this MsgBox is displayed, press Ctrl+Break.  Then click on the Retry button.  As soon as you click on Retry, Visual Basic will return to the Break mode and the line where the error occurred will be highlighted.


TIPS
Unregistered Software - Please Register today!

Tips

(Important tips at bottom of this topic, too.)

•	While developing your application, use "In-line" error checking.  Here is an example:

On Error Resume Next
f$ = Dir$("a:\myfile.dat")
e% = Err
On Error Goto 0
If e% Then
     ' process error e%
End If
   :

Later, when you run Trapper on this code, it will add generic error trapping to this procedure.  Trapper would change the On Error Goto 0 to On Error Goto ProcedureName_Error.  The "inline" error checking is left unaffected, but unexpected errors outside of this "inline" trapping will be handled by the Trapper generated code.

•	Don't run Trapper too soon and...

•	Remember what Trapper will do for you.

     Running Trapper too soon in the development cycle can make debugging your program difficult.  The VB IDE is provided to assist you in trapping errors.  If you have generic error trapping enabled in every procedure you are likely to miss obvious mistakes and get unpredictable results.  Include error checking where you see that obvious errors may occur, or can't be avoided.  (Drive Not Ready, for example.)
    Keep in mind, as you are coding, what Trapper will do for you at the "end game."  Think to yourself if the following message box will be adequate:

     Realize what options this message box gives your end users:

1	Abort:  Code will exit the current procedure and continue.

2	Retry:  Code will resume at the statement that caused the error.

3	Ignore:  Program execution will resume at the next statement following the statement that caused the error.

If these options, or a variation of them, are adequate for the procedure you are writing, then you need not write any special error checking into the procedure.  You can let Trapper add it later.

•	It is easy to change the Trapper generated code.  Often times an "Ignore" option is not acceptable.  Changing the generated code is normally easier than adding your own.

•	Good Project Management is required.  Trapper will not output the generated code to the same file name.  Therefore, you must Remove the old and Add the new.

Watch those .ERR files!

•	When you do run Trapper, I suggest you copy the Project Make file to a new name.  For this project, I used ETRAPPER.MAK.  Manually edit this make file to change the extensions to .ERR as required.

Load and run this project.  If the results aren't disastrous, then:

1	Make backup copies of the originals.

2	Copy the .ERR files over the original files.

3	Delete the .ERR files and Error Make file.

4	Finish your project.

      Why do all this?  Keeping two copies of your project files is confusing and can lead to a mistake that results in a loss of effort.

Trap One Project File at a Time

•	Numerous duplicate files can be hard to maintain and debug.

•	It is not uncommon to have ABC.FRM and ABC.BAS in one project.  Trapper will propose ABC.ERR as the output file for both.  This is why I emphasize doing one file at a time and getting rid of the duplicates as soon as possible.  Keeping a .ERR file in your project is a bad habit.

Debugging after running Trapper

•	After running Trapper on a form or module, errors that occur will result in the Abort, Retry, Ignore message box.  To see where the error occurred, press Ctrl+Break while this message box is displayed.  Then click on the Retry button.

Visual Basic will enter the Break mode and the line that caused the error will be highlighted.


THANK YOU
Unregistered Software - Please Register today!

Thank You for trying Trapper

Thanks for taking the time to give Trapper a try.  I welcome comments from all users, registered or not.  Send your feedback to me via CompuServe.

Jack Presley

CompuServe ID:  70700,166


READ THIS
Ombudsman

Presley Computing tries to provide the best support possible.

If you are not satisfied, this notice contains helpful information:

This program is produced by Presley Computing, a member of the Association of Shareware Professionals (ASP). ASP wants to make sure that the shareware principle works for you. If you are unable to resolve a shareware-related problem with an ASP member by contacting the member directly, ASP may be able to help. The ASP Ombudsman can help you resolve a dispute or problem with an ASP member, but does not provide technical support for members' products.

Please write to the ASP Ombudsman at:
545 Grover Road
Muskegon, MI 49442-9427 USA

FAX 616-788-2765 or send a CompuServe message via CompuServe
Mail to ASP Ombudsman 70007,3536.

This is not for Technical Support.

For Technical Support contact:

1	Jack Presley via CompuServe mail to 70700,166

2	Post a message to Jack Presley  70700,166 in section 17 (Third-Party) of the MSBASIC forum on CompuServe.

3	Send regular mail to:
Jack Presley
Presley Computing
29322 Mandetta Drive
Fair Oaks Ranch, TX 78006-4529

4	Phone Presley Computing, (210) 981-9554 between 7:30am and 7:30pm Central Time.


common dialog

A standard set of Windows dialog boxes for opening and saving files, printing, choosing colors, etc.  CMDIALOG.VBX gives you access to these standard dialog boxes.


CONSTANT.TXT

CONSTANT.TXT is installed, by default, in the VB subdirectory.  Can't find it?  That's okay.  Call up VB.HLP and read the topic on the MsgBox function.  These constants are explained and defined in this topic.  Add these constants, exactly as they are spelled here, to the declarations section of a module in your project.


enabled

Controls that appear "grayed out" are not enabled.  Clicking on these controls will have no affect.


Fair Oaks Ranch

Home of Presley Computing located just North of San Antonio, Texas.  You will sometimes see our address as Boerne (pronounced Bernie).  The Boerne Post Office services this area.


IDE

Integrated Development Environment


Presley Computing

A small software development and consulting company located in beautiful Fair Oaks Ranch, in the Hill Country of Texas.  We specialize in Visual Basic and Access programming, application automation, and small computer consulting.  Jack Presley, the owner, is the author of Trapper.


SWREG

Acronym for CompuServes Shareware Registration service.  If you would like to register your own copy of Trapper, GO SWREG at the ! prompt on CompuServe.  When prompted, register program #2360.  CompuServe will add the registration fee to regular billing and will notify me of your registration.  You will promptly receive your own registered copy of Trapper!  It's that easy.


Trapper

A program that generates BASIC error trapping routines for each procedure in a text source code file.


Visual Basic

Visual Basic refers to Microsoft Visual Basic for Windows and Microsoft Visual Basic for DOS.  Trapper will work with other Basic products, but generated code may need modification.  Regardless of the product, files must be saved in text format.  I am interested in the results you have using other products.